package com.ror.java.se.thread;

//setPriority(int newPriority) 设置线程的优先级，取值范围1-10，默认5
//守护线程：当其他的非守护线程执行完毕之后，守护线程会陆续结束

public class Demo04 {
    public static void main(String[] args) {
        MyRun mr = new MyRun();
        Thread t1 = new Thread(mr, "飞机");
        t1.setPriority(10);
        t1.start();
        Thread t2 = new Thread(mr, "发动机");
        t2.setPriority(1);
        t2.setDaemon(true); //发动机是飞机的守护线程
        t2.start();
    }

    private static class MyRun implements Runnable {
        @Override
        public void run() {
            for (int i = 0; i < 50; i++) {
                System.out.println(Thread.currentThread().getName() + ": " + i);
            }
        }
    }
}
